import 'dart:io';

import 'package:flutter/services.dart';

class RouterUtils {
  static final String METHOD_CHANNEL_KEY = "gapsk-acp";
  static final String PAGE_NAME_KEY = "pageName";

  static Future<T> goToNativePage<T>(String pageName,
      [Map<String, dynamic> params]) {
    if (Platform.isAndroid) {
      if (params != null) {
        params[PAGE_NAME_KEY] = pageName;
        return MethodChannel(METHOD_CHANNEL_KEY)
            .invokeMethod<T>("goToPage", params);
      }
      return MethodChannel(METHOD_CHANNEL_KEY)
          .invokeMethod<T>("goToPage", {PAGE_NAME_KEY: pageName});
    }
  }
}
